<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
    Document   : Grading Page
    Created on : 1st April2014
    Author     :Ihab Ali
-->
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui" 
      xmlns:f="http://java.sun.com/jsf/core">


    <body>

        <ui:composition template="./WEB-INF/templates/template.xhtml">

            <ui:define name="content">
                
              <h:form rendered="#{login.loggedIn == false}" >
                  <h3>#{messages.messageNotAuthintecated}</h3>
                  <h:commandButton action="/index?faces-redirect=true"
                                   value="#{messages.loginLabel}" />
              </h:form>

                <p:dataTable value="#{listControl.questions}" var="q" rendered="#{login.loggedIn}">
                    <f:facet name="header">  
                        #{messages.ExamResultHeader}
                    </f:facet>  
                    <p:column>  
                        <f:facet name="header">  
                            #{messages.questionLabel}
                        </f:facet>  
                        <h:outputText value="#{q.question}" />  
                    </p:column>  
                    <p:column>  
                        <f:facet name="header">  
                            #{messages.yourAnswerLabel}
                        </f:facet>  
                        <h:outputText value="#{q.savedanswer}" />  
                    </p:column> 
                    
                     <p:column>  
                        <f:facet name="header">  
                            #{messages.correctAnswer}
                        </f:facet>  
                         <h:outputText value="#{q.answer}" />  
                    </p:column>
                    
                    <p:column>  
                        <f:facet name="header">  
                            #{messages.statusLabel}
                        </f:facet>  
                        <h:graphicImage library="images" name="#{q.checkAnswer()}" />
                    </p:column>
                    <f:facet name="footer">  
                        #{messages.correctAnswer}s &nbsp; : #{listControl.correctAnswer} / #{listControl.questions.size()}<br/>
                        #{messages.average} &nbsp;&nbsp;: #{listControl.avg}%<br/>
                        #{messages.Grade} &nbsp;&nbsp;  : #{listControl.grade}
                    </f:facet>  
                </p:dataTable>

                <p:panelGrid columns="2" rendered="#{login.loggedIn}">
                    <p:commandButton action="#{listControl.downloadResults()}" value="#{messages.Download}" />
                    <p:commandButton action="#{listControl.logOut()}" value="#{messages.LogOut}" />
                </p:panelGrid>

            </ui:define>
        </ui:composition>
    </body>
</html>
